package com.is2.patchinglife.wrapper;

import android.annotation.SuppressLint;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;


public class AppConfiguration{
	
	private String user;
	private String pwd;
	private String cookieValue;
	private String cookieName;
	private boolean effects = true;
	private boolean vibration = true;
	
	private Hashtable<String,SensorConf> sensorConf;

	public String getUser(){return user;}
	public void setUser(String _user){user = _user;}
	
	public String getPwd(){return pwd;}
	public void setPwd(String _pwd){pwd = _pwd;}
	
	public String getCookieValue(){if(cookieValue==null)cookieValue=""; return cookieValue;}
	public void setCookieValue(String _cookie){cookieValue = _cookie;}
	
	public String getCookieName(){return cookieName;}
	public void setCookieName(String _cookie){cookieName = _cookie;}
	
	public Hashtable<String,SensorConf> getSensorConf(){return sensorConf;}
	public void setSensorConf(Hashtable<String,SensorConf> _conf){sensorConf = _conf;}
	
	public boolean getVibration(){return vibration;}
	public void setVibration(boolean _v){vibration=_v;}
	
	public boolean getEffects(){return effects;}
	public void setEffects(boolean _e){effects=_e;}
	
	/** Verify if auto-login is settled **/
	public boolean isAuth(){
		String loggedUser = getCookieValue().toString();
		if(loggedUser != null && !loggedUser.equals("")){
			return true;
		}
		return false;
	}
	
	@SuppressLint("DefaultLocale")
	public String toString(){
		String temp = "::::: GENERAL SETTING :::::\n"+
					  "name: "+user+"\n"+
					  "pwd: "+pwd+"\n"+
					  "cookieName: "+cookieName+"\n"+
					  "cookieValue: "+cookieValue+"\n";
		
		temp += "\nsensor configuration:\n";
		Enumeration<String> e = sensorConf.keys();
		while(e.hasMoreElements()){
			String sensor_key = (String) e.nextElement();
			temp += sensor_key.toUpperCase(Locale.ENGLISH)+"\n";
			temp += sensorConf.get(sensor_key).toString()+"\n";
		}
		
		return temp;
	}
	
}
